package com.union;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

public class CommonPagerAdapter extends PagerAdapter
{
	private List<? extends View> views;
	
	public CommonPagerAdapter(List<? extends View> views)
	{
		this.views = views;
	}
	
	@Override
	public Object instantiateItem(ViewGroup container, int position)
	{
		View view = views.get(position);
		container.addView(view);
		return view;
	}
	
	@Override
	public void destroyItem(ViewGroup container, int position, Object object)
	{
		container.removeView(views.get(position));
	}
	
	@Override
	public int getCount()
	{
		return views.size();
	}
	
	@Override
	public boolean isViewFromObject(View view, Object object)
	{
		return view == object;
	}
	
	public void refreshViews(List<? extends View> views)
	{
		this.views = views;
		notifyDataSetChanged();
	}
}
